package com.lx.top;

import com.lx.entitys.CovidTopEntity;
import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: chenjiang
 * @Date: 2021/11/18/21:14
 * @Description:
 */
public class CovidGroupingComparator extends WritableComparator {
    protected CovidGroupingComparator() {
        super(CovidTopEntity.class, true);
    }

    /***
     * compareTo 方法 =0 相等 其余的数据不等 包括>0 <0
     * @param a
     * @param b
     * @return
     */
    @Override
    public int compare(WritableComparable a, WritableComparable b) {
        CovidTopEntity aBean = (CovidTopEntity) a;
        CovidTopEntity bBean = (CovidTopEntity) b;

        return aBean.getState().compareTo(bBean.getState());
    }
}
